import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
 {
  path: '/',
  // 路由懒加载
   component: () => import('@/views/layout/Layout.vue'),
   children: [
      {
          // 默认子路由
        path: '',
        component:()=>import('@/views/Home/Home.vue')
      },
      {
        path: '/qa',
        component:()=>import('@/views/Home/Qa.vue')
      },
      {
        path: '/video',
        component:()=>import('@/views/Home/Video.vue')
      },
      {
        path: '/my',
        component: () => import('@/views/Home/My.vue'),
        
        
      },
    ]
  },
  {
    path: '/login',
    // 路由懒加载
    component:()=>import('@/views/login/Login.vue')
  },
  {
    path: '/search',
    component:()=> import('@/views/search/Search.vue')
  },
  {
    // 设置一个动态路由 根据 跳转传递  id 可以在 this.$router.params  里面找到
    path: '/article/:articleId',
    name:'/article',
    component: () => import('@/views/article/Article.vue'),
    props:true , //开启路由传参， articleId 接收的 值 -》 props
  },
  {
    path: '/user/profile',
    component:()=>import('@/views/user-profile/userfile.vue')
  }
]

const router = new VueRouter({
  routes
})

export default router
